Skip to content

Finished runs never leave their pull request a draft silently - #501

Merged
nambok merged 1 commit into
mainfrom
finished-runs-never-silently-draft
Nov 7, 2026
Merged

nambok merged 1 commit into
mainfrom
finished-runs-never-silently-draft

Conversation

@nambok

@nambok nambok commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

A finished run's pull request never stays a draft without a reason a person can act on, and marking it ready can't be lost.

What happened: a new-feature run finished with the repository's CI green and CoderHelm's review approving, and its pull request stayed a draft. Four of CoderHelm's own sandbox checks had failed on the head, feature::ready_hold returned on them, and mark_pr_ready returned without a word. The run page said completed, and no "marked ready" or "stays a draft" line was logged. The same day, mark-ready messages that hit GitHub's rate limit were logged as "Mark PR ready failed" and dropped, so five more pull requests were never marked ready.

Now there is one decision, passes::ready::decide, and every path goes through ready::settle: the run's own completion, the mark-ready message, an end-to-end proof that held, and a new sweep. It returns Ready { open }, Held { reasons } (each reason says what holds it and what to do), Wait { why, until }, or Closed.

Which holds stay, and which became open items

Default to progress: a hold must be something a person has to decide, or a named correctness, security or data-loss problem.

Kept as holds (the PR stays a draft, and the run is needs_input):

  • Security items open in the description.
  • Planned work not done ("Not finished"): the change doesn't yet do what was asked.
  • A check the change didn't pass, listed under Open items (carried-over commits, missing registrations, a migration that can't be released safely, redirects).
  • CoderHelm's own review findings not yet fixed.
  • A stacked change asking for a look first.
  • A person put the PR back to draft. CoderHelm never undoes that.
  • A failing-test fix that loosens the test or adds a wait with no timing failure behind it. Such a fix can hide the bug.
  • A failing-test fix whose ready check gave up after its rechecks (about 12 hours).
  • Redirect and link checks that fail when checked now.
  • An end-to-end fix whose proof was refused.
  • CoderHelm's own sandbox failures and checklist items, but only while CI isn't green or the review hasn't approved. The reason names which one.

Waits (no person needed; CoderHelm decides again by itself, and the run page says what it waits for):

  • A failing-test fix whose checks are still running or whose repeat run hasn't passed yet.
  • An end-to-end fix or new test whose repeat runs are going, or haven't proved it yet.

Became open items (the PR is marked ready and they are listed under Open items):

  • CoderHelm's own sandbox check failures (sandbox_failed), once the repository's CI is green on the head and CoderHelm's review approved it.
  • Verification checklist items (tests per acceptance case and per option, end-to-end spec, test map entry, content skips, responsive checks). Every item on that list is about tests, none is a correctness, security or data-loss finding, so they count the same way.

Changes

  • services/worker/src/passes/ready.rs (new): decide (pure), settle, on_message, the run-record writes, the retry, and sweep. Each choice is explained in comments next to the code.
  • A hold is never silent:
    • It is logged at warn with its reasons.
    • It is written at the top of the description in a new section that CoderHelm owns (completeness::Section::DraftStatus), and removed once the PR is ready.
    • It is recorded on the run as draft_hold (common::draft_hold).
    • A hold a person must act on sets a finished run to needs_input, with a WaitingOn naming the pull request and the reasons. The status write goes through NeedsInput::needs_input, as the run_wait rule requires, and the run.needs_input event is sent.
    • That status change is a handoff to a person, so it goes through the stop judge's record (stop_judge::cannot_proceed, kind handoff, step draft_hold). No model is asked, because decide has already kept only what a person must act on. The source rule that every needs_input write holds a judged decision still passes.
    • Because the decision runs before the run's status is written, end_run checks the run again right after it writes completed (ready::after_completion).
  • Mark-ready can't be lost:
    • MarkReadyMessage gains run_id, attempt, not_before and squash_keep_first, all serde-defaulted, so old messages still parse.
    • When GitHub refuses (its rate limit, a 5xx, or a pull request or timeline it won't serve), the decision is sent again. It waits until GitHub's reset when GitHub names one (clients::github::outside_wait, from Runs wait out GitHub's limits instead of failing; refused writes are never "no file" #499), otherwise it backs off. A wait longer than one SQS delay goes in hops.
    • It tries at most common::github_wait::MAX_WAITS times. The last refusal is recorded on the run as a failed hold and written in the description.
    • "Could not read the PR timeline — leaving the draft as is" is now a retry.
  • The sweep runs with the stuck-review sweep (every 15 minutes).
    • It scans finished runs from the last 14 days that have a PR and no draft_settled, and makes at most 40 decisions per sweep.
    • It decides again for every run with no recorded hold, which is how past casualties heal. It also decides again for any hold more than an hour old.
    • For newer holds it only checks whether a person has marked the PR ready or closed it.
    • Closed PRs and a person's draft are respected.
    • It is a table scan, the same kind of scan the stuck-run lambda already does every 10 minutes.
  • feature::ready_hold now returns its items as structured data (FeatureHold) instead of a joined string, and a read failure no longer holds the draft. The Open items wording no longer says these items keep the draft.
  • test_fix::Hold gains Refused (a loosened test or an unjustified wait: a person decides) and GaveUp (out of rechecks), next to Wait.
  • proof::with_marked_items is the general version of with_security_items, which now uses it.
  • Gateway: the run detail returns draft_hold (kind, summary, reasons[{what, todo}], pr_number, since). docs/api/openapi.json is regenerated.
  • Incident case s_silent_draft and its row in docs/incidents.md. Incident k now checks the shared decision instead of the old mark-ready function in main.rs.

Dashboard (not changed here): the run page should show draft_hold.summary whenever draft_hold is set, for example "Finished, but pull request #21 stays a draft: ...". It should list each reason with its todo. A needs_input run with a draft_hold should read as "Finished, PR held" rather than "Needs input".

Verification

  • cargo fmt --check
  • cargo clippy -p common -p gateway -p worker --all-targets -- -D warnings
  • cargo test -p common -p gateway -p worker: common 1505 passed (plus 2 in no_hosted_urls), gateway 748 passed, worker 1370 passed, 0 failed
  • New tests:
    • ready::tests: each hold and open-item choice, the description section written once and removed once ready, open items not listed twice, CoderHelm's own checks left out of CI, retry backoff and the rate-limit wait, message compatibility, and the sweep's choice per run.
    • common::draft_hold::tests.
    • incidents::s_silent_draft: the incident replayed, every path going through the one decision with no silent return, the retry and the final failure, and the sweep healing a silent draft.

One decision (passes::ready::decide) now settles every pull request a
finished run leaves, on every path: the run's own completion, the
mark-ready message, an end-to-end proof that held, and a new sweep.

- With the repository's CI green and CoderHelm's review approving,
  CoderHelm's own sandbox failures and checklist items no longer hold the
  draft: the pull request is marked ready with them under Open items.
- What a person must decide still holds it: security items, planned work
  not done, a failed check, open own-review findings, a stacked change, a
  person's draft, a loosened test, failing redirects.
- A hold is logged at warn, written at the top of the description, and
  recorded on the run (draft_hold); a hold a person must act on makes the
  finished run needs_input with what to do.
- A mark-ready GitHub refuses is sent again after its reset, at most
  MAX_WAITS times; the last refusal is recorded on the run.
- The sweep decides again for finished runs left a draft with no reason.
- The run API returns draft_hold; incident case s_silent_draft.
@nambok
nambok merged commit 40d3bb5 into main Nov 7, 2026
10 checks passed
@nambok
nambok deleted the finished-runs-never-silently-draft branch November 7, 2026 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant